package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.netca.bmps.userservice.bo.CertInfo;
import net.netca.bmps.userservice.bo.CertInfoLocal;
import net.netca.bmps.userservice.service.UserService;
import net.netca.bmps.userservice.servicelayer.UserServiceImpl;
import net.netca.gdltax.bpms.businessmanage.utilits.Base64Encoder;
import net.netca.gdltax.bpms.businessmanage.utilits.Converter;
import net.netca.gdltax.bpms.webservice.CertServiceClient;
import net.netca.gdltax.bpms.webservice.CertServicePortType;
import net.netca.testwebservice.bo.XMLConfig;
import net.netca.util.encoders.Base64;

@SuppressWarnings("serial")
public class UnlockPin extends HttpServlet {
	public UnlockPin() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
	 
//		CertServiceClient client = new CertServiceClient("http://192.168.0.37:8082/businessmanage/services/CertService");
		CertServiceClient client = new CertServiceClient(XMLConfig.getInstance().getUrl());
		CertServicePortType service = client.getCertServiceHttpPort();
		String sn = request.getParameter("keysn");
		String userPin = request.getParameter("userPin");
	
		String soPIN = service.getSoPin(sn);
		
		
		// 安装时需要的数据
		
		request.getSession().setAttribute("userPin", userPin);
		request.getSession().setAttribute("soPin", soPIN);
		
		response.setCharacterEncoding("UTF-8");
		response.sendRedirect("../unlockPin2.jsp");
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

	public void init() throws ServletException {
	}
}
